package com.ayg.controller;

import com.ayg.pojo.Life;
import com.ayg.service.LifeService;
import com.ayg.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/life")
@CrossOrigin
public class LifeController {

    @Autowired
    private LifeService lifeService;

    @Value("${file.localDir}")
    private String localDir;    //获取磁盘路径
    @Value("${file.urlPath}")   //spel表达式
    private String urlPath;     //获取虚拟路径


    @PostMapping("/AddLifeUpload")
    public SysResult AddLifeUpload(@RequestBody Life life){
        lifeService.addLifeUpload(life);
        return SysResult.success();
    }

    @GetMapping("/getLifeList")
    public SysResult getLifeList(){
        List<Life> lifeList=lifeService.getLifeList();
        return SysResult.success(lifeList);
    }
}
